package com.zx.idc.backend.gui.scheduler.slog.hotdomain;

import com.zx.idc.ds.slog.service.ISlogHotDomainService;
import com.zx.idc.ds.slog.service.ISlogHotIpService;
import com.zx.idc.ds.slog.service.ISlogHotUrlService;
import com.zx.idc.ds.sys.entity.SysConfiguration;
import com.zx.idc.ds.sys.service.ISysConfigurationService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 活跃资源日志定时任务实现类
 */
public class SlogHotDomainScheduledJob implements Job {

    @Autowired
    private ISlogHotDomainService iSlogHotDomainService;
    @Autowired
    private ISlogHotIpService iSlogHotIpService;

    @Autowired
    private ISlogHotUrlService iSlogHotUrlService;

    @Autowired
    private ISysConfigurationService iSysConfigurationService;


    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        SysConfiguration sysConfiguration=iSysConfigurationService.selectOne(new SysConfiguration().setConfigKey("sysSettings_retain_icp_day"));
        Integer configValue=Integer.parseInt(sysConfiguration.getConfigValue());
        if(configValue>0){
            iSlogHotDomainService.deleteByTime(configValue);
            iSlogHotIpService.deleteByTime(configValue);
            iSlogHotUrlService.deleteByLastTime(configValue);
        }
    }
}
